package io.renren.modules.psnetpoint.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.psnetpoint.entity.PsNetPointEntity;
import io.renren.modules.psnetpoint.service.PsNetPointService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 网点表
 * 
 * @author wangdajiang
 * @email 2750757088@qq.com
 * @date 2018-04-08 14:34:05
 */
@RestController
@RequestMapping("/psnetpoint")
public class PsNetPointController {
	@Autowired
	private PsNetPointService psNetPointService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("psnetpoint:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<PsNetPointEntity> psNetPointList = psNetPointService.queryList(query);
		int total = psNetPointService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(psNetPointList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("psnetpoint:info")
	public R info(@PathVariable("id") Long id){
		PsNetPointEntity psNetPoint = psNetPointService.queryObject(id);
		
		return R.ok().put("psNetPoint", psNetPoint);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("psnetpoint:save")
	public R save(@RequestBody PsNetPointEntity psNetPoint){
		psNetPointService.save(psNetPoint);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("psnetpoint:update")
	public R update(@RequestBody PsNetPointEntity psNetPoint){
		psNetPointService.update(psNetPoint);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("psnetpoint:delete")
	public R delete(@RequestBody Long[] ids){
		psNetPointService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
